//问题： 结构体可否直接赋值

#include <iostream>

#include <string>
#include <string.h>
using namespace std;

struct A
{
    char a[10];
};

struct B
{
    char *b;
};

struct C
{
    string c;
};

int main()
{
    A a1;
    strcpy(a1.a, "aaa");

    A a2;
    a2 = a1; //深拷贝without defining the = operator
    printf("%s,  %s ,     %p ,   %p\n", a1.a, a2.a, a1.a, a2.a);

    printf("\n-----------------------------------------\n");

    B b1;
    b1.b = new char[10];
    strcpy(b1.b, "bbb");

    B b2 = b1; //浅拷贝
    printf("%s,  %s ,     %p ,   %p\n", b1.b, b2.b, b1.b, b2.b);

    printf("\n-----------------------------------------\n");

    C c1;
    c1.c = string("ccc");

    C c2 = c1; //深拷贝
    printf("%s,  %s ,     %p ,   %p\n", c1.c.c_str(), c2.c.c_str(), c1.c.c_str(), c2.c.c_str());
}